<template>
  <div>
    <button @click="fh">返回</button>
    <h2>搜索的结果是:</h2>
    <div class="q1" v-for="item in result" :key="item">
      <img :src="item.img" /> <span>{{ item.title }}</span>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      list: [],
      result: [],
    };
  },
  mounted() {
    this.$axios.get("http://localhost:8080/list.json").then((res) => {
      this.list = res.data.data;
      this.getres();
    });
  },
  methods: {
    getres() {
      let res = this.list.filter((item) => {
        return item.title.includes(this.$route.query.value);
      });
      this.result = res;
    },
    fh() {
      this.$router.push({ path: "/" });
    },
  },
};
</script>
<style scoped>
img {
  width: 80px;
  height: 80px;
  float: left;
  margin: 10px;
}
span {
  float: left;
  line-height: 80px;
  margin-left: 30px;
}
.q1 {
  width: 356px;
  height: 100px;
  border: 1px solid rgb(0, 255, 166);
  margin-top: 10px;
  margin-left: 30px;
}
</style>